﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace monitor_server_2_WPF.CustomControls
{
    /// <summary>
    /// Логика взаимодействия для TrayControl.xaml
    /// </summary>
    public partial class TrayControl
    {
        public TrayControl()
        {
            InitializeComponent();
            DispBorder.Background = new SolidColorBrush(Res.LighBlack);
            DispLabel.Text = Res.Rm.GetString("NewLogEntries") + ':';
            UsersLabel.Text = Res.Rm.GetString("UsersOnline") + ':';
            SetServerState(false);
        }

        public void SetServerState(bool started)
        {
            if (started)
            {
                ServerLabel.Text = Res.Rm.GetString("ServerStarted");
                ServerLabel.Foreground = new SolidColorBrush(Colors.GreenYellow);
            }
            else
            {
                ServerLabel.Text = Res.Rm.GetString("ServerStopped");
                ServerLabel.Foreground = new SolidColorBrush(Colors.Wheat);
            }
        }

        public void SetUnreadMessages(string text)
        {
            DispText.Text = text;
        }

        public void SetUsers(string userCount)
        {
            UsersText.Text = userCount;
        }

        public void SetStatus(Status status)
        {
            switch (status)
            {
                case Status.Alarm:
                    DispBorder.BorderBrush = new SolidColorBrush(Res.WarningOrange);
                    break;
                case Status.Error:
                    DispBorder.BorderBrush = new SolidColorBrush(Colors.Red);
                    break;
                case Status.Ok:
                    DispBorder.BorderBrush = new SolidColorBrush(Res.NiceBlue);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("status");
            }
        }

        public enum Status
        {
            Alarm,
            Error,
            Ok
        }

    }
}
